using System;
using System.Collections.Generic;
using CSI.Directory.Core.Model;
using CSI.Directory.Core.Services;
using CSI.Directory.Repo;
using SubSonic.Repository;

namespace C3.Directory.Repo
{
    public class ProfileRepository : RepositoryBase, IProfileRepository
    {
        public User GetUserByName(string username)
        {
            return repo.Single<User>(t => t.Name == username);
        }

        public IList<User> GetAllContentManagers()
        {
            return repo.Find<User>(t => t.Roles != string.Empty);
        }

        public int CreateContentManager(User u)
        {
            repo.Add(u);
            return u.Id;
        }

        public int DeleteContentManager(User u)
        {
            return repo.Delete<User>(u.Id);
        }

        public int RoleContentManager(User u)
        {
            return repo.Update(u);
        }

        public User GetUserById(int id)
        {
            return repo.Single<User>(t => t.Id == id);
        }
    }
}